const dbutil = require('../../../libs/MyDB');

module.exports = {
    login: async function (data) {
        let users = [];
        await dbutil.multiSelect('res_user','*',`openid='${data.openid}'`)
            .then(
                result => {
                    users = result;
                }
            )
        if(users.length==0){
            await dbutil.add('res_user',data)
                .then(
                    res=>{
                        users = res;
                    }
                )
        }
        return {
            code: 200,
            msg: "登录成功",
            data: users,
            count: users.length,
        }
    }
}